#include "HTTPResponseHeaders.h"


HTTPResponseHeaders::HTTPResponseHeaders(void)
{
	Sent = false;
}


HTTPResponseHeaders::~HTTPResponseHeaders(void)
{

}

void HTTPResponseHeaders::AddHeader(string Name, string Value)
{
	mHeaders.push_back(pair<string, string>(Name, Value));
}

void HTTPResponseHeaders::SetResponseCode(int Code, string Desc, string Version)
{
	mResponseCode = Version + " " + StdToStr<int>(Code) + " " + Desc;
}

string HTTPResponseHeaders::ToString()
{
	string Output = mResponseCode + "\r\n";
	for(auto it = mHeaders.begin(); it != mHeaders.end(); ++it)
	{
		Output += it->first + ": " + it->second + "\r\n";
	}
	Output += "\r\n";
	Sent = true;
	return Output;
}

void HTTPResponseHeaders::operator += (pair<string, string> aHeader)
{
	mHeaders.push_back(aHeader);
}

bool HTTPResponseHeaders::HaveSent()
{
	return Sent;
}